/**
 * Allure report model
 */
export type Time = {
  start: number;
  stop: number;
  duration: number;
};

export type Summary = {
  statistic: {
    failed: number;
    broken: number;
    skipped: number;
    passed: number;
    unknown: number;
    total: number;
  };
  time: Time;
};

export type Attachment = {
  uid: string;
  name: string;
  source: string;
  type: string;
  size: number;
};

export type Parameter = {
  name: string;
  value: string;
};

export const severities = ["trivial", "minor", "normal", "critical", "blocker"] as const;
export type Severity = (typeof severities)[number];

export const statuses = ["passed", "failed", "skipped", "broken", "unknown"] as const;
export type Status = (typeof statuses)[number];

export type Stage = {
  name?: string;
  time?: Time;
  status: Status;
  statusMessage?: string;
  statusTrace?: string;
  steps: Stage[];
  attachments: Attachment[];
  parameters: Parameter[];
  shouldDisplayMessage: boolean;
  stepsCount: number;
  attachmentsCount: number;
  hasContent: boolean;
};

export type Label = {
  name: string;
  value: string;
};

export type Extra = {
  severity: Severity;
  owner: string;
  tags: string[];
};

export type Test = {
  uid: string;
  name: string;
  fullName: string;
  historyId: string;
  time: Time;
  status: Status;
  statusMessage: string;
  statusTrace: string;
  flaky: boolean;
  newFailed: boolean;
  newBroken: boolean;
  newPassed: boolean;
  retriesCount: number;
  retriesStatusChange: boolean;
  beforeStages: Stage[];
  testStage: Stage;
  afterStages: Stage[];
  labels: Label[];
  parameters: Parameter[];
  hidden: boolean;
  retry: boolean;
  extra: Extra;
  source: string;
  parameterValues: string[];
};

// Definitions
export type TaskLocator = {
  url: string;
  name: string;
  number: number;
};

export const issues = ["bug", "script", "env"] as const;
export type Issue = (typeof issues)[number];
